Auto merge of #3510 - froydnj:cross-compilation-test-checking, r=alexcrichton
authorbors <bors@rust-lang.org>
Mon, 9 Jan 2017 04:20:40 +0000 (04:20 +0000)
committerbors <bors@rust-lang.org>
Mon, 9 Jan 2017 04:20:40 +0000 (04:20 +0000)
commitf70194a56e70bab2f4e37aba525604c2025a3d63
tree314458c08d80058a7b2e838084f76f46339a896e
parent40a4ce61b0114ee3b4b31205ad00e59df5be692f
parentbbc1079877c5ef3daa829953976877ecea0d0ebd
Auto merge of #3510 - froydnj:cross-compilation-test-checking, r=alexcrichton

handle cross-compilation test failure more gracefully

The current cross-compilation test module fails every test if an appropriate cross standard library is not found.  This behavior is unhelpful, because the failures are verbose, unexpected, and there's no
obvious way to make them go away.

Instead, it would be better to check once before all the tests that an appropriate cross-compilation setup is available.  Once that check has been done, a single test can fail with an appropriate `panic!` message while the other tests silently pass.  The `panic!` message can inform the user about their options, either setting an appropriate environment variable, or using rustup to install the necessary cross standard library.

Assuming the user has rustup installed, the single failure now looks
something like:

```
thread 'plugin_deps' panicked at 'Cannot cross compile to i686-unknown-linux-gnu.

This failure can be safely ignored. If you would prefer to not see this
failure, you can set the environment variable CFG_DISABLE_CROSS_TESTS to "1".

Alternatively, you can install the necessary libraries for cross-compilation with

    rustup toolchain install stable-i686-unknown-linux-gnu
', tests/cross-compile.rs:87
note: Run with `RUST_BACKTRACE=1` for a backtrace.
```

The code is admittedly gnarly, with synchronization and `unsafe` sections, but I wasn't sure how to make it any better. Suggestions welcome!

Fixes #3086.